package luj.tool.jnproxyan.proxy.network.socks.reply;

import io.netty.buffer.ByteBuf;
import luj.net.api.server.ConnectionAcceptInitializer;


/**
 * @see luj.tool.jnproxyan.proxy.network.socksv2.server.handler.S5CommandReqHandler#channelRead0
 */
@Deprecated
public class SocksReplyMaker {

  public SocksReplyMaker(ConnectionAcceptInitializer.Connection conn) {
    _conn = conn;
  }

  // https://www.ietf.org/rfc/rfc1928.txt
  // 6.  Replies
  public ByteBuf make(int reply) {
    return _conn.alloc().buffer()
        .writeByte(0x05)  // VER
        .writeByte(reply) // REP
        .writeByte(0x00)  // RSV
        .writeByte(0x01)  // ATYP
        .writeInt(0)      // BND.ADDR
        .writeShort(0);   // BND.PORT
  }

  private final ConnectionAcceptInitializer.Connection _conn;
}
